<script setup>
import axios from 'axios'
import { ref } from 'vue'
var userid = ref(0)
var title = ref("")
var body = ref("")
var price = ref(0)
var picPaths = ref("")
var typeIndex = ref(2)
var productdesc = ref("")
function addcomment(data) {
    axios.post("/api/demo/additem", {
        title: title.value,
        body: body.value,
        userid: userid.value
    }).then(response => {
        console.log(Response.data)
    })
}
function addproduct() {
    axios.post("/api/demo/additem", ({
        title: title.value,
        price:price.value,
        productdesc: productdesc.value,
        picPaths: picPaths.value,
        userid: userid.value,
        typeIndex:typeIndex.value
    })).then(response=>{
       console.length(response.data)
    })
}



</script>
<template>
    <div class="add">
        <div>
            id:<input type="text" v-model="userid">
            标题：<input type="text" v-model="title">
            内容：<input type="text" v-model="body">
            <button @click="addcomment">点击发表评论</button>
        </div>
        <div>
            <h1>添加商品不可用</h1>
            标题<input type="text" v-model="title">
            价格<input type="text" v-model="price">
            介绍<input type="text" v-model="productdesc">
            图片路径<input type="text" v-model="picPaths">
            用户id<input type="text" v-model="userid">
            索引<input type="text" v-model="typeIndex">
            <button @click="addproduct">点击发表产品信息</button>
        </div>
    </div>


</template>